package com.csdj.sc.common.base;

import com.csdj.sc.common.constant.WebMsgConstant;
import org.springframework.util.StringUtils;

import javax.servlet.http.HttpServletRequest;
import java.util.Locale;

public class BaseController {

    /**
     * 获取语言类型
     * @param request
     * @return
     */
    public Locale getLang(HttpServletRequest request){
        String header = request.getHeader("Accept-Language");
        if(StringUtils.hasText(header)){
            String lang = header.split(",")[0];
            Locale locale = Locale.forLanguageTag(lang);
            return locale;
        }
        return Locale.CHINA;
    }
}
